package com.fz.controller.system;

import com.fz.common.ResponseEntity;
import com.fz.beans.IdBeans;
import com.fz.beans.PageBeans;
import com.fz.dto.system.dictionaryValue.DictionaryValueAdd;
import com.fz.dto.system.dictionaryValue.DictionaryValueQuery;
import com.fz.dto.system.dictionaryValue.DictionaryValueUpd;
import com.fz.service.system.DictionaryValueService;
import com.fz.vo.system.dictionaryValue.DictionaryValueVo;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author :xmj
 * @date :2021/3/24 上午9:37
 */

@RestController
@Api(value = "字典值管理", tags = "字典值管理")
@RequestMapping("/dictionaryValue")
@ApiSort(value = 9)
public class DictionaryValueController {

    @Resource
    private DictionaryValueService dictionaryValueService;


    @GetMapping("/findDictionaryValueList")
    @ApiOperation(value = "查询字典值分页")
    @ApiOperationSupport(order = 1)
    public ResponseEntity<DictionaryValueVo> findDictionaryValueList(DictionaryValueQuery dictionaryValueQuery, PageBeans pageBeans) {
        return dictionaryValueService.findDictionaryValueList(pageBeans.getPageNum(), pageBeans.getPageSize(), dictionaryValueQuery);
    }

    @PostMapping("/saveDictionaryValue")
    @ApiOperation(value = "新增字典值")
    @ApiOperationSupport(order = 2)
    public ResponseEntity saveDictionaryValue(@RequestBody DictionaryValueAdd dictionaryValueAdd) throws Exception {
        return dictionaryValueService.saveDictionaryValue(dictionaryValueAdd);
    }

    @PostMapping("/updateDictionaryValue")
    @ApiOperation(value = "修改字典值")
    @ApiOperationSupport(order = 3)
    public ResponseEntity updateDictionaryValue(@RequestBody DictionaryValueUpd dictionaryValueUpd) throws Exception {
        return dictionaryValueService.updateDictionaryValue(dictionaryValueUpd);
    }

    @PostMapping("/delDictionaryValue")
    @ApiOperation(value = "删除字典值")
    @ApiOperationSupport(order = 4)
    public ResponseEntity delDictionaryValue(@RequestBody IdBeans idBeans) throws Exception {
        return dictionaryValueService.delDictionaryValue(idBeans.getIds());
    }
}
